<template>
  <div class="WorkingSchedule" v-loading="loading">
    <el-form ref="form" :model="form" label-position="top" class="myform">
      <div>
        <el-form-item label="下单日期" class="myform-item">
          <el-date-picker
            v-model="form.str_time"
            type="monthrange"
            align="right"
            unlink-panels
            range-separator="至"
            start-placeholder="开始月份"
            end-placeholder="结束月份"
            value-format="yyyy-MM"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="款号/加工单号" class="myform-item">
          <el-input
            v-model="form.type_no"
            placeholder="请输入款号/加工单号"
            clearable
            @keyup.enter.native="onSearch"
          ></el-input>
        </el-form-item>
        <el-form-item label="运营下单编号" class="myform-item">
          <el-input
            v-model="form.order_number"
            placeholder="请输入运营下单编号"
            clearable
            @keyup.enter.native="onSearch"
          ></el-input>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="margin-top: 50px">
          <el-button type="primary" @click="onSearch">查询</el-button>
        </el-form-item>
      </div>
    </el-form>
    <el-table
      ref="multipleTable"
      :data="tableData"
      style="width: 100%"
      border
      size="mini"
    >
      <el-table-column
        label="运营下单信息"
        align="center"
        prop="order_number"
        width="200"
      >
        <template slot-scope="{ row }">
          <div class="orderInfo">
            <div class="orderInfo-one">
              <div class="orderInfo-one-left">{{ row.order_number }}</div>
              <div class="orderInfo-one-right">
                <!-- <div>翻单</div> -->
                <div
                  :style="{
                    borderColor: row.approval_state == 0 ? '' : '#67C23A',
                  }"
                >
                  {{ row.approval_state == 0 ? "未结案" : "已结案" }}
                </div>
              </div>
            </div>
            <div class="orderInfo-two">
              <div>批次：{{ row.batch }}</div>
              <div>下单数：{{ row.total_count }}</div>
            </div>
            <!-- <div class="orderInfo-three">
              <div>运营下单入库比例：</div>
              <div>
                <el-progress
                  :text-inside="true"
                  :stroke-width="14"
                  :percentage="70"
                ></el-progress>
              </div>
            </div> -->
            <!-- <div class="orderInfo-four">
              <div class="orderInfo-four-title">
                订单预期/实际跨度：<span>50/</span><span>60</span>天
              </div>
              <div>
                <el-steps :active="2" align-center>
                  <el-step
                    title="10-11"
                    description="运营下单"
                  ></el-step>
                  <el-step
                    title="10-15"
                    description="内部货期"
                  ></el-step>
                  <el-step
                    title="10-18"
                    description="完结日期"
                  ></el-step>
                </el-steps>
              </div>
            </div> -->
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="商品信息"
        align="center"
        prop="processing_code"
        width="300"
      >
        <template slot-scope="{ row }">
          <div class="goodsInfoModule">
            <div
              class="goodsInfo"
              v-for="(item, index) in row.product_list"
              :key="index"
            >
              <el-image
                :src="item.image"
                fit="contain"
                :preview-src-list="[item.image]"
                :lazy="true"
              ></el-image>
              <div>
                <div>{{ item.type_name }}</div>
                <div>
                  {{ item.type_no }}
                  <span>{{ item.design_classification }}</span>
                </div>
              </div>
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="生产加工单信息"
        align="center"
        prop="processing_list"
        width="1100"
      >
        <template slot-scope="{ row }">
          <el-table :data="row.processing_list" size="mini">
            <el-table-column label="" align="center" prop="s_status">
              <template slot-scope="{ row }">
                {{ row.s_status | s_status }}
              </template>
            </el-table-column>
            <el-table-column
              label="基本信息"
              align="center"
              prop="processing_code"
              width="600"
            >
              <template scope="{ row }">
                <div class="Processing">
                  <!-- <div class="Processing-left">
                延期
              </div> -->
                  <div class="Processing-right">
                    <div class="Processing-right-one">
                      <div>{{ row.processing_code }}</div>
                      <div
                        :style="{
                          borderColor:
                            row.s_status == 3 || row.s_status == 4
                              ? '#67C23A'
                              : '',
                        }"
                      >
                        {{
                          row.s_status == 3 || row.s_status == 4
                            ? "已结案"
                            : "未结案"
                        }}
                      </div>
                      <div>理单员：{{ row.order_processor }}</div>
                    </div>
                    <div>
                      <el-steps :active="0" align-center>
                        <el-step
                          :title="row.add_date || '暂无'"
                          description="下单时间"
                        ></el-step>
                        <el-step
                          :title="row.contract_date || '暂无'"
                          description="加工厂合同货期"
                        ></el-step>
                        <el-step
                          :title="row.production_date || '暂无'"
                          description="生成回复时间"
                        ></el-step>
                        <el-step title="暂无" description="完结时间"></el-step>
                      </el-steps>
                    </div>
                  </div>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              label="入库数/下单数/入库比例"
              align="center"
              prop="processing_code"
            >
              <template slot-scope="{ row }">
                {{ row.qty }}/{{ row.countnum }}/{{ row.rate }}%
              </template>
            </el-table-column>
            <el-table-column label="单价" align="center" prop="unit_price">
            </el-table-column>
            <el-table-column label="生产/裁剪数量" align="center" prop="">
            </el-table-column>
            <el-table-column label="金额" align="center">
              <template slot-scope="{ row }">
                {{ floatMultiply(row.countnum, row.unit_price) }}
              </template>
            </el-table-column>
          </el-table>
        </template>
      </el-table-column>
      <el-table-column label="封样" align="center">
        <el-table-column label="是否需要封样" align="center" prop="">
        </el-table-column>
        <el-table-column label="封样批复时间" align="center" prop="">
        </el-table-column>
      </el-table-column>
      <el-table-column label="绣花厂" align="center" prop="embroidery_factory">
      </el-table-column>
      <el-table-column label="印花厂" align="center" prop="printing_factory">
      </el-table-column>
      <el-table-column label="烫金厂" align="center" prop="bronzing_factory">
      </el-table-column>
      <el-table-column label="批次状态" align="center" prop="processing_code">
      </el-table-column>
      <el-table-column
        label="批次延期情况"
        align="center"
        prop="processing_code"
      >
        <!-- <template slot-scope="{ row }">
          <div class="Extension">
            {{ row.processing_code }}
          </div>
        </template> -->
      </el-table-column>
      <el-table-column
        label="工厂裁剪日期"
        align="center"
        prop="processing_code"
      >
      </el-table-column>
      <el-table-column label="裁剪总数" align="center" prop="processing_code">
      </el-table-column>
      <el-table-column label="首次/首件完成时间" align="center">
        <el-table-column
          label="绣花首次完成"
          align="center"
          prop="processing_code"
        >
        </el-table-column>
        <el-table-column
          label="工厂首件完成"
          align="center"
          prop="processing_code"
        >
        </el-table-column>
      </el-table-column>
      <el-table-column
        label="裁剪完成入库比例"
        align="center"
        prop="processing_code"
      >
      </el-table-column>
      <el-table-column label="入库总数" align="center" prop="processing_code">
      </el-table-column>
      <el-table-column
        label="成品待入库数"
        align="center"
        prop="processing_code"
      >
      </el-table-column>
      <el-table-column
        label="合同货期内入库数"
        align="center"
        prop="processing_code"
      >
      </el-table-column>
      <el-table-column
        label="超期<=7天入库数"
        align="center"
        prop="processing_code"
      >
      </el-table-column>
      <el-table-column
        label="超期>7天入库数"
        align="center"
        prop="processing_code"
      >
      </el-table-column>
    </el-table>
    <pagination
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postAdminOperateGetoperation_order"
    />
  </div>
</template>

<script>
import { postAdminOperateGetoperation_order } from "@/api";
import pagination from "@/components/pagination.vue";
import { floatMultiply } from "@/utils/algorithm.js";

export default {
  components: { pagination },
  filters: {
    s_status(e) {
      if (e == 0) return "未审核";
      if (e == 1) return "已审核";
      if (e == 2) return "已结案";
      if (e == 3) return "已同步";
    },
  },
  data() {
    return {
      loading: false,
      form: {
        str_time: "",
        end_time: "",
        order_number: "",
        type_no: "",
        page: 1,
        size: 10,
      },
      tableData: [],
      total: 1,
    };
  },
  activated() {
    let form = this.form;
    this.postAdminOperateGetoperation_order(form);
  },
  methods: {
    floatMultiply(n1, n2) {
      return floatMultiply(Number(n1), Number(n2));
    },
    // 采购列表
    async postAdminOperateGetoperation_order(data) {
      this.loading = true;
      this.form = data;
      postAdminOperateGetoperation_order(data)
        .then((res) => {
          this.loading = false;
          console.log("列表", res);
          this.tableData = res.data;
          this.total = Number(res.total);
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    // 搜索
    onSearch() {
      let date = this.form.str_time;
      if (date) {
        if (Array.isArray(date)) {
          this.form.str_time = date[0];
          this.form.end_time = date[1];
        }
      } else {
        this.form.str_time = "";
        this.form.end_time = "";
      }
      this.form.page = 1;
      this.form.size = 10;
      this.postAdminOperateGetoperation_order(this.form);
    },
  },
};
</script>

<style lang="scss" scoped>
.Processing {
  width: 360px;
  /deep/ .el-step__title {
    font-size: 12px;
    line-height: 26px;
  }
  /deep/.el-step__icon {
    width: 20px;
    height: 20px;
  }
  .Processing-left {
    width: 40px;
    background: red;
    color: #fff;
  }
  .Processing-right {
    padding: 10px;
    width: 600px;
    .Processing-right-one {
      display: flex;

      justify-content: center;
      align-items: center;
      margin-bottom: 20px;
      > div:nth-child(1) {
        font-size: 14px;
        font-weight: 600;
      }
      > div:nth-child(2) {
        width: 60px;
        height: 24px;
        line-height: 24px;
        text-align: center;
        border-radius: 2px;
        border-width: 1px;
        border-style: solid;
        border-color: #999;
        margin: 0 10px;
      }
    }
  }
}

.orderInfo {
  /deep/ .el-step__title {
    font-size: 12px;
    line-height: 26px;
  }
  /deep/.el-step__icon {
    width: 20px;
    height: 20px;
  }
  padding: 10px;
  .orderInfo-one {
    display: flex;
    align-items: center;
    .orderInfo-one-left {
      font-size: 14px;
      font-weight: 600;
    }
    .orderInfo-one-right {
      display: flex;
      > div {
        width: 60px;
        height: 24px;
        line-height: 24px;
        text-align: center;
        border-radius: 2px;
        border-width: 1px;
        border-style: solid;
        border-color: #999;
        margin-left: 20px;
      }
    }
  }
  .orderInfo-two {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px dashed #999;
    > div:nth-child(1) {
      margin-right: 20px;
    }
  }
  .orderInfo-three {
    text-align: left;
    border-bottom: 1px dashed #999;
    padding: 10px 0;
    > div:nth-child(1) {
      padding-bottom: 10px;
    }
  }
  .orderInfo-four {
    .orderInfo-four-title {
      > span {
        font-size: 16px;
        font-weight: 600;
      }
      > span:nth-child(2) {
        color: red;
      }
    }
  }
}
.Extension {
  width: 100px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  background: #dd2929;
  color: #ffff;
  margin: 10px auto;
}
.goodsInfoModule {
  > div:not(:nth-last-child(1)) {
    border-bottom: 1px solid #ebeef5;
  }
  > div {
    height: 129px;
  }
  > div:nth-child(1) {
    height: 200px;
  }
}
.goodsInfo {
  display: flex;
  align-items: center;
  //   padding: 10px;
  > .el-image {
    width: 50px;
    height: 50px;
  }
  > div {
    text-align: left;
    width: 210px;
    margin-left: 10px;
    > div:nth-child(1) {
      font-weight: 600;
    }
    > div:nth-child(2) {
      > span {
        color: #999999;
      }
    }
  }
}
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.WorkingSchedule {
  background: #ffff;
  padding: 20px;
  border-radius: 2px;
  @include boxShadow;
  /deep/ .el-table .cell {
    padding: 0 !important;
  }
  /deep/ .el-table--mini td {
    padding: 0 !important;
  }
  /deep/ .el-table--mini th {
    padding: 12px 0 !important;
  }
}
</style>